set more 1

/*
File:	cepr_org_demog.do
Date:	Nov 14, 2005, CEPR ORG Version 1.0
	Mar 12, 2015, CEPR ORG Version 2.0
	Apr  1, 2015, CEPR ORG Version 2.0.1
	March 1, 2016, CEPR ORG Version 2.1
	Oct 12, 2016, CEPR ORG Version 2.1.1
	Feb 9, 2017, CEPR ORG Version 2.2
	Apr 21, 2017, CEPR ORG Version 2.2.1
	Apr 10, 2018, CEPR ORG Version 2.3
	Mar 22, 2019, CEPR ORG Version 2.4
	Jul 24, 2019, CEPR ORG Version 2.4.1
	Feb 05, 2020, CEPR ORG Version 2.5
	
Desc:	Creates consistent demographic variables for CEPR consistent extract
	of CPS ORG
Note:	See copyright notice at end of program.
*/

/* Determine data year */

local year=year in 1
if `year'==-17345 {local year  = 1980}
di "`year'"

/* Age */

lab var age "Age"
notes age: CPS: a-age, peage

/* Gender */

gen byte female=0 if sex==1
replace female=1 if sex==2
lab var female "Female"
notes female: CPS: derived from a-sex, pesex

/* Race and ethnicity */

if 1979<=`year' & `year'<=1988 {
gen byte wbho=1 if race==1
replace wbho=2 if race==2
replace wbho=4 if race==3
replace wbho=3 if (1<=ethnic & ethnic<=7)
}
if 1989<=`year' & `year'<=1993 {
gen byte wbho=1 if race==1
replace wbho=2 if race==2
replace wbho=4 if (3<=race & race<=5)
replace wbho=3 if (1<=ethnic & ethnic<=7)
}
lab var wbho "Race"
#delimit ;
lab define wbho
1 "White"
2 "Black"
3 "Hispanic"
4 "Other"
;
#delimit cr
lab val wbho wbho
notes wbho: Racial and ethnic categories are mutually exclusive
notes wbho: CPS: derived from a-race, perace, a-reorgn, prorigin

	/* Race and ethnicity --separate category for Asian Pacific */

gen byte wbhao=.
gen byte wbhaom=.
if 1979<=`year' & `year'<=1988 {
*missing
}
if 1989<=`year' & `year'<=1993 {
replace wbhao=1 if race==1 /* white */
replace wbhao=2 if race==2 /* black */
replace wbhao=4 if race==4 /* asian */
replace wbhao=5 if race==3 | race==5 /* other & amer indian, alaskan native */
replace wbhao=3 if (1<=ethnic & ethnic<=7) /* hispanic */
}

lab var wbhao "Race/ethnicity, inc. Asian"
lab def wbhao 1 White 2 Black 3 Hispanic 4 Asian 5 Other
lab val wbhao wbhao
notes wbhao: Racial and ethnic categories are mutually exclusive
notes wbhao: From 2003, black includes all respondents listing black; asian /*
*/ includes all respondents listing asian; other includes all respondents /*
*/ listing non-white, non-black or non-asian races, excluding those also /*
*/ listing black or asian
notes wbhao: asians include hawaiian/pacific islanders
notes wbhao: CPS: derived from prdthsp a-reorgn
notes wbhao: Available 89-on only

/* Race category 2003- */

gen byte wbhom=.
gen byte racehpi=.
gen byte racehpia=.
gen byte racea=.

/* Foreign-born status (from 1994 only) */

if 1979<=`year' & `year'<=1993 {
/* unavailable */
gen byte forborn=.
gen byte citizen=.
gen byte prcitshp=.
gen penatvty=.
gen pemntvty=.
gen pefntvty=.
gen prinusyr=.
gen byte arrived=.
}

lab var forborn "Foreign born"
notes forborn: CPS: derived from prcitshp
notes forborn: Not available 1979-1993

lab var citizen "US citizen"
notes citizen: CPS: derived from prcitshp
notes citizen: Not available 1979-1993

lab var prcitshp "Citizenship status"
notes prcitshp: CPS: prcitshp
notes prcitshp: Not available 1979-1993

lab var arrived "Year entered US"

capture lab drop arrived
#delimit ;
lab define arrived
1 "<1950"	
2 "1950-59"
3 "1960-64"
4 "1965-69"
5 "1970-74"
6 "1975-79"
7 "1980-81"
8 "1982-83"
9 "1984-85"
10 "1986-87"
11 "1988-89"
12 "1990-91"
13 "1992-";
#delimit cr
lab val arrived arrived

notes arrived: See "prinusyr" for year-specific variable
notes arrived: CPS: prinusyr
notes arrived: Not available 1979-1993

lab var prinusyr "Year entered US"
notes prinusyr: See "arrived" for variable that is consistent over time
notes prinusyr: CPS: prinusyr
notes prinusyr: Not available 1979-1993

lab var penatvty "Country of birth"
notes penatvty: CPS: penatvty
notes penatvty: Not available 1979-1993

lab var pemntvty "Country birth, mother"
lab val pemntvty cob
notes pemntvty: CPS: pemntvty
notes pemntvty: Not available 1979-1993

lab var pefntvty "Country birth, father"
lab val pefntvty cob
notes pefntvty: CPS: pefntvty
notes pefntvty: Not available 1979-1993

/* Veteran */

if 1979<=`year' & `year'<=1988 {
gen byte vet=0 if veteran~=.
replace vet=1 if (1<=veteran & veteran<=5)
replace vet=. if female==1
}
if 1989<=`year' & `year'<=1993 {
gen byte vet=0 if veteran~=.
replace vet=1 if (1<=veteran & veteran<=5)
}
lab var vet "Veteran"
notes vet: Question not asked consistently of women before 1989
notes vet: CPS: derived from a-vet, peafwhen

/* 
Copyright 2020 CEPR and John Schmitt

This file is part of the cepr_org_master.do program. This file and all
programs referenced in it are free software. You can redistribute the
program or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
USA.
*/

